package com.example.myapplication.anim;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;

import com.example.myapplication.R;
import com.example.myapplication.anim.AppCleanView;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class TestActivity2 extends AppCompatActivity implements AppCleanView.onAnimationListener{

    List<Drawable> mList = new ArrayList<>();
    AppCleanView appView;
    Handler handler = new Handler();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test2);
        initData();
    }

    @Override
    protected void onResume() {
        super.onResume();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                appView.startItemAnimators();

            }
        },500);

    }


    @Override
    protected void onDestroy() {
        appView.destroy();
        super.onDestroy();
    }

    @Override
    protected void onStart() {
        super.onStart();
        appView.initData(mList);
    }

    private void initData() {
        appView = findViewById(R.id.app_view);
        appView.setOnAnimationListener(this);
        mList.add(getResources().getDrawable(R.drawable.icon_battery));
        mList.add(getResources().getDrawable(R.drawable.icon_big_file));
        mList.add(getResources().getDrawable(R.drawable.ic_push_big_file_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_big_file_02));
        mList.add(getResources().getDrawable(R.drawable.ic_push_cool_down_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_cool_down_02));
        mList.add(getResources().getDrawable(R.drawable.ic_push_clean_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_clean_02));
        mList.add(getResources().getDrawable(R.drawable.icon_battery));
        mList.add(getResources().getDrawable(R.drawable.icon_big_file));
        mList.add(getResources().getDrawable(R.drawable.ic_push_big_file_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_big_file_02));
        mList.add(getResources().getDrawable(R.drawable.ic_push_cool_down_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_cool_down_02));
        mList.add(getResources().getDrawable(R.drawable.ic_push_clean_01));
        mList.add(getResources().getDrawable(R.drawable.ic_push_clean_02));
    }

    @Override
    public void onDataCreated() {
        appView.startLayoutAnimation();
    }

    @Override
    public void onAnimationOver() {
        Log.i("llll", "onAnimationOver: "+"over");
    }
}